<!DOCTYPE html>
<html>
<head>
    <title>Dialog.html</title>
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" href="js\layui-v2.5.6\layui\css\layui.css">
    <script src="js\layui-v2.5.6\layui\layui.js"></script>
    <script src="js\layui-v2.5.6\layui\layui.all.js"></script>
    <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script>

    <script type="text/javascript">
        function getRootPath() {
            var strFullPath = window.document.location.href;
            // var strPath = window.document.location.pathname;
            // var pos = strFullPath.lastIndexOf(strPath);
            // var prePath = strFullPath.substring(0, pos+1);
            // var prePath = strFullPath.substring(0, pos+1);
            // var postPath = strPath.substring(0, strPath.substr(1).indexOf('/') + 1);
            var temp = strFullPath.substring(0, strFullPath.lastIndexOf("/")+1);


            return temp;
        }
        function getContextPath() {
            var basePath = getRootPath();
            var pos = basePath.substring(0, basePath.length-1).lastIndexOf("/");
            var temp = basePath.substring(pos, basePath.length);
            return temp;

        }
        var basePath = getRootPath();
        var contextPath = getContextPath();
    </script>
</head>
<body>
<fieldset class="layui-elem-field layui-field-title ">
    <legend>
        <li id="icon"
            class="layui-icon layui-icon-face-smile layui-anim layui-anim-rotate "
            style="font-size: 30px; color: #1E9FFF;"
            data-anim="layui-anim-rotate"></li> <span style="font-size: 8px">请输入借书信息</span>
    </legend>
    <br>
    <div class="layui-field-box" style="width: 97%">
        <form class="layui-form" action="">
            <div class="layui-form-item">
                <label class="layui-form-label">姓名 :</label>
                <div class="layui-input-block">
                    <input type="text" name="stuname" id="stuname" disabled="disabled"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">书名 :</label>
                <div class="layui-input-block">
                    <input type="text" name="bookname" id="bookname" disabled="disabled"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">用户名/学号  :</label>
                <div class="layui-input-block">
                    <input type="text" name="username" id="username" lay-verify="title"
                           autocomplete="off" placeholder="请输入学号或用户名" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux"></div>
            </div>
            <br>
            <br>
        </form>
    </div>
</fieldset>
<script type="text/javascript">
    layui.use(['layer', 'table','element','form','laydate'], function(){
        var form = layui.form,
            layer = layui.layer,
            layedit = layui.layedit,
            laydate = layui.laydate;
        //日期控件
        var dag=window.parent;
        laydate.render({
            elem: '#issueDate'
        });
        form.render();
    });
    //监听身份证信息
    $(function(){
        $("#username").blur(function(){
            var value=$(this).val();
            $.ajax({
                async:true,  //异步加载
                data:{"id":value}, //参数
                type:"get",
                url:basePath + "BookController/getName",
                dataType:"json",
                success:function(data){
                    // var toObj = JSON.parse(data);
                    if(data.data.length <= 0){
                        layer.msg("没有该学号的学生", {icon: 5});
                    }
                    //转化成JSON字符串
                    $("#stuname").val(data.data);
                }
            });
        });
    });
</script>
</body>
</html>